package com.octo.poker.data;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

import com.octo.poker.BestHandFinder;

public class Hand {
	private Collection<Card> cards;

	/**
	 * Example of Hand creation :
	 *
	 * new Hand("4S", "2D", "JH", "JC", "AD");
	 */
	public Hand(String... cards) {
		this.cards = new ArrayList<Card>();
		for (String s : cards) {
			this.cards.add(Card.parse(s));
		}
	}

	public Collection<Card> getcards() {
		return new ArrayList<Card>(cards);
	}
	
	public int getBestLevel(){
		if(BestHandFinder.isRoyalFlush(this))	return 9;
		if(BestHandFinder.isStraightFlush(this))	return 8;
		if(BestHandFinder.isFourOfAKind(this))	return 7;
		if(BestHandFinder.isFullHouse(this))	return 6;
		if(BestHandFinder.isFlush(this))	return 5;
		if(BestHandFinder.isStraight(this))	return 4;
		if(BestHandFinder.isThreeOfAKind(this))	return 3;
		if(BestHandFinder.isTwoPair(this))	return 2;
		if(BestHandFinder.isPair(this))	return 1;
		return 0;
	}
	
	public String toString(){
		String s = "";
		System.out.println(cards.size());
		for(Card c : this.cards){
			s += c.toString() + " ";
		}
		return s;
	}
}
